-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional group theory functions for error correction #351
Conversation
@KDGoodenough I have rewritten the documentation for |
…mClifford.jl into loc-comm-embed fixed merge conflict with origin
I think I have completed all the requested changes, but I am not aware of more uses of Additionally, should I add the newly-referenced papers to references.md? |
@IsaacP1234 I think it's good like this! There's not too much work (yet!) that uses this commutify business. My guess would be that yes, it would be good to add these references to the .md file as well, but Stefan would know better. |
Changelog:
|
…cally for you, causing less noise in PRs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally got around to reviewing this. Thank you for all these additions and apologies for the long delay.
First, I made a few changes myself, but either github is having its usual reliability problems or you have set some security features a bit higher and I can not push to your branch.
Before you continue, could you please make sure that you pull the changes from this branch: https://github.com/QuantumSavory/QuantumClifford.jl/tree/loc-comm-embed
I tried to make each commit small and self-explanatory -- please check the commits I have added one-by-one to see why they were added.
m::Int | ||
k::Int | ||
end | ||
function SubsystemCodeTableau(t::Tableau) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this constructor necessary? It is a pretty expensive one. Should this not be a part of the canonicalize_noncomm
function itself.
src/grouptableaux.jl
Outdated
end | ||
|
||
|
||
Base.copy(t::SubsystemCodeTableau) = SubsystemCodeTableau(copy(t.tab)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very expensive way to make a copy as you are redoing a ton of computation. It would be better if this just copies over the various indices as well.
src/grouptableaux.jl
Outdated
for i in 0:2^n-1 | ||
for (digit_order, j) in enumerate(digits(i, base=2, pad=n)) | ||
if j == 1 | ||
group[i+1] *= s[digit_order] | ||
group[i+1] *= gen_set[digit_order] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mul_left!(group, gen_set, i+1, digit_order)
would be drastically faster (it will be in-place, avoiding a lot of allocations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, does this function work correctly if there are terms with non-trivial phases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are non-real phases it doesn't work because it uses minimal_generating_set
which only accepts real phases. Should I rework it to work with imaginary phases or specify in the docs that it only accepts real phases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, there doesn't seem to be any method of mul_left!
that can multiply a single row of a Tableau
or Stabilizer
by a Pauli. Just indexing doesn't change the original structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just writing down what we discussed in the call: just add a kwargument phases=false, and throw an error if someone tries to run phases=true with some message about it not being implemented
For mul_left!
could you please just add a new method for it, basically just making a second more general version of this one in the same file
QuantumClifford.jl/src/mul_leftright.jl
Line 166 in 4e06c01
@inline function mul_left!(s::Tableau, m, i; phases::Val{B}=Val(true)) where B |
I think it would be just
@inline function mul_left!(s::Tableau, m, t::Tableau, i; phases::Val{B}=Val(true)) where B
extra_phase = mul_left!((@view s.xzs[:,m]), (@view t.xzs[:,i]); phases=phases)
B && (s.phases[m] = (extra_phase+s.phases[m]+s.phases[i])&0x3)
s
end
and then do tab(stabilizer)
wherever you call it
src/grouptableaux.jl
Outdated
julia> tab(logical_operator_canonicalize(QuantumClifford.Tableau([P"XX", P"XZ", P"XY"]))) | ||
+ Z_ | ||
+ XX | ||
-iX_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, let's just remove the phases
src/grouptableaux.jl
Outdated
for k in eachindex(t) | ||
if k !=i && k != j | ||
if comm(t[k], t[i]) == 0x01 | ||
t[k] = t[j] *t[k] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mul_left!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with phases=false
src/grouptableaux.jl
Outdated
loc[index]= t[i] | ||
index+=1 | ||
end | ||
if !(t[j] in loc || -1 *t[j] in loc || 1im *t[j] in loc || -1im * t[j] in loc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment about cost of check
src/grouptableaux.jl
Outdated
while length(loc) > 1 && loc[length(loc)-1] == zero(PauliOperator, nqubits(loc)) | ||
loc = loc[1:(length(loc)-1)] | ||
end | ||
return SubsystemCodeTableau(loc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give the constructor more information so it does not run all that expensive processing and searching?
src/grouptableaux.jl
Outdated
puttableau!(commutative, x, i, nqubits(loc)+i) | ||
puttableau!(commutative, z, i+loc.r+loc.k, nqubits(loc)+i) | ||
end | ||
to_delete = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something more like nqubits+1:nqubits+k
would be much simpler and faster
src/grouptableaux.jl
Outdated
+ ZZZ | ||
|
||
julia> matroid_parent(T"XX")[2] | ||
1-element Vector{Any}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should be ranges or vectors of ints, not vectors of any
src/grouptableaux.jl
Outdated
3 | ||
|
||
julia> matroid_parent(T"XX")[3] | ||
Any[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should be ranges or vectors of ints, not vectors of any
by the way, to verify my claims about speed, you can use |
All requested chnages complete. For the |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #351 +/- ##
==========================================
- Coverage 83.11% 82.53% -0.59%
==========================================
Files 70 70
Lines 4418 4580 +162
==========================================
+ Hits 3672 3780 +108
- Misses 746 800 +54 ☔ View full report in Codecov by Sentry. |
Finally merged! Thanks so much! |
Adding logical_operator_canonicalize, commutavise, and embed functions, as well as SubsystemCodeTableau datastructure and minor performance improvements for groupify and normalizer.